package com.whucke.multi.datasource.service.impl;

import com.whucke.multi.datasource.domain.User;
import com.whucke.multi.datasource.repository.first.UserRepository;
import com.whucke.multi.datasource.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * User Service Interface Impl
 *
 * @author zhang peng
 * @since 2019/3/6 10:16
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public User save(User user) {
        return userRepository.save(user);
    }

    @Override
    @Transactional(transactionManager = "firstTransactionManager")
    public User save(String name, Integer age) {
        User user = new User();
        user.setName(name);
        user.setAge(age);
        return save(user);
    }
}
